<% if not request.xhr? %>
<table class="ajax-scaffold" cellpadding="0" cellspacing="0">
  <tbody>
<% end %>
<tr id="create-bookmark-<%= @temp_id %>" class="create" <%= "style=\"display: none;\"" if request.xhr? %>>
  <td colspan="5" class="create" style="background: #DAFFCD;">
  	<% if request.xhr? %>
    	<%= form_remote_tag :url => { :controller => 'bookmarks', :action => 'create' }, 
    			:loading => "AjaxScaffold.createOnLoading(request,'bookmark',#{@temp_id});",
    			:success => "AjaxScaffold.createOnSuccess(request,'bookmark',#{@temp_id});",
    			:failure => "AjaxScaffold.createOnFailure(request,'bookmark',#{@temp_id});",
    			:html => { :action => url_for(:controller => 'bookmarks', :action => 'create'),
                     :id => "create-bookmark-#{@temp_id}-form" } %>
    <% else %>  
    	<%= form_remote_tag :url => { :controller => 'bookmarks', :action => 'create' }, 
    			:loading => "window.close();",
    			:success => "window.close();",
    			:failure => "AjaxScaffold.createOnFailure(request,'bookmark');",
    			:html => { :action => url_for(:controller => 'bookmarks', :action => 'create'),
                     :id => "create-bookmark-#{@temp_id}-form" } %>
    <% end %>
      <h4>New Bookmark</h4>
      
      <% # Its actually okay to leave both of these elements (ex: form_errors will only generate HTML when in fallback mode) %>
      <% if request.xhr? %>
        <div id="<%= "create-bookmark-#{@temp_id}-errors" %>" style="display: none;" ></div>
      <% else %>
        <%= render :partial => 'form_errors' %>
      <% end %>
            
      <%= render :partial => 'form' %>
      
      <p>
      	<%= submit_tag "Create", :class => "submit" %>
      	<% if request.xhr? %>
      	<%= link_to_function "Cancel", "AjaxScaffold.createOnCancel('bookmark',#{@temp_id});",
	                      :href => url_for(:controller => 'bookmarks', :action => 'return_to_main') %>
	      <% else %>
	      <input type="button" value="Cancel" onclick="javascript:window.close();" />
	      <% end %>
      	<%= loading_indicator_tag 'bookmark', "create-#{@temp_id}" %>
    	</p>
    <%= end_form_tag %>
  </td>
</tr>
